//
//  OrderHistoryCell.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/23.
//  Copyright © 2020 tym. All rights reserved.
//

#import "OrderHistoryCell.h"
#import "UIView+ZFFrame.h"
@interface OrderHistoryCell()

@property(nonatomic,weak) UILabel *titLab;
@property(nonatomic,weak) UILabel *timeLab;
@property(nonatomic,weak) UILabel *locationLab;
@property(nonatomic,weak) UIButton *actionBtn;

@end

@implementation OrderHistoryCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    [self inintUI];
    return self;
}

-(void)inintUI{
    
    TYMLabel *lab = [TYMLabel lb_text:@"zhinengsuo" font:Font_Medium(15) color:rgba(74, 74, 74)];
    lab.frame = CGRectMake(15, 11.5, 200, 21);
    [self.contentView addSubview:lab];
    self.titLab = lab;
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, ScreenWidth - 30, 1)];
    lineView.backgroundColor = rgba(230, 230, 230);
    [self.contentView addSubview:lineView];
    
    TYMButton *btn = [TYMButton buttonWithType:UIButtonTypeSystem];
    [btn setTitle:@"待处理" forState:UIControlStateNormal];
    btn.frame = CGRectMake((ScreenWidth-30)-70, 11.5, 55, 21);
    [self.contentView addSubview:btn];
    self.actionBtn = btn;
    
    UIImageView *timeLeft = [[UIImageView alloc] initWithFrame:CGRectMake(13, 63, 12, 12)];
    timeLeft.image = [UIImage imageNamed:@"icon_times"];
    [self.contentView addSubview:timeLeft];
    
    TYMLabel *timeLeftLb  = [TYMLabel lb_text:@"提交时间" font:Font_Regular(14) color:rgba(155, 155, 155)];
    timeLeftLb.frame = CGRectMake(33, 59, 70, 20);
    [self.contentView addSubview:timeLeftLb];
    
    TYMLabel *timeLab = [TYMLabel lb_text:@"13:45" font:Font_Regular(14) color:rgba(155, 155, 155)];
    timeLab.textAlignment = NSTextAlignmentRight;
    timeLab.frame = CGRectMake((ScreenWidth-30)-150-15, 60, 150, 20);
    [self.contentView addSubview:timeLab];
    self.timeLab = timeLab;
    
    UIImageView *addressLeft = [[UIImageView alloc] initWithFrame:CGRectMake(13, 97.5, 12, 12)];
    addressLeft.image = [UIImage imageNamed:@"icon_times"];
    [self.contentView addSubview:addressLeft];
    
    TYMLabel *addLeftLb  = [TYMLabel lb_text:@"服务地址" font:Font_Regular(14) color:rgba(155, 155, 155)];
    addLeftLb.frame = CGRectMake(33, 94, 70, 20);
    [self.contentView addSubview:addLeftLb];
    
    TYMLabel *addLab = [TYMLabel lb_text:@"" font:Font_Regular(14) color:rgba(155, 155, 155)];
    addLab.frame = CGRectMake(addLeftLb.zf_right+5, 94, ScreenWidth-30-addLeftLb.zf_right-20, 20);
    addLab.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:addLab];
    self.locationLab  = addLab;
}

-(void)setRepaireModel:(RepairsApplyModel *)repaireModel{
    
    self.locationLab.text = [NSString stringWithFormat:@"%@%@%@",repaireModel.city,repaireModel.district,repaireModel.address];
    
    self.timeLab.text = repaireModel.createTime;
    
    if(repaireModel.contacts){
        self.titLab.text = @"订单状态";
    }else{
        self.titLab.text = [NSString stringWithFormat:@"维修%@",repaireModel.equipmentName];
    }
    [self.actionBtn setTitle:[repaireModel getStatusStr] forState:UIControlStateNormal];
}

+(CGFloat)cellForHeight{
    return 129;
}

+(NSString*)identifier{
    return @"OrderHistoryCell";
}
@end
